package cn.zqh.brand.rabbitmq;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: zqh
 * @Date: 2023-03-15-13:46
 * @Description: rabbitmq配置$
 */
@Configuration
public class MyRabbitConfig1 {

    private static String EXCHANGE_NAME = "ms7";
    private static String QUEUE_NAME = "ms_queue7";

    /**
     * @Author: zqh
     * @Date:
     * @Description: 上面交换机
     */
    @Bean
    public FanoutExchange exchange(){
        return new FanoutExchange(EXCHANGE_NAME,true,false);
    }

    /**
     * @Author: zqh
     * @Date:
     * @Description: 声明队列
     */
    @Bean
    public Queue queue(){
        return new Queue(QUEUE_NAME,true,false,false);
    }

    /**
     * @Author: zqh
     * @Date:
     * @Description: 声明绑定关系
     */
    @Bean
    public Binding queueBinding(Queue queue, FanoutExchange fanoutExchange){
        return BindingBuilder.bind(queue).to(fanoutExchange);
    }

}
